﻿<div class="topbar" id="topbar">
    <div class="container clearfix">
        <div class="backhome fl">
            <a href="/index.html" class='backhome-text'>回到首页</a>
            <a href="javascript:void(0);" class='publish-text' id="publish-text"></a>
        </div>
        <div class="links fr">
            <ul id="ulUnlogin" class="hide">
                <li>
                    <a href="javascript:void(0);" class="link-login">登录</a>
                    <div class="link-list">
                        <p><a href="/login.html?type=Company">企业账号登录</a></p>
                        <p><a href="/login.html?type=Personal">社团账号登录</a></p>
                        <p><a href="/login.html?type=Agent">代理官账号登录</a></p>
                    </div>
                </li>
                <li>
                    <a id="btnApply" href="/personal/register.html">注册申请</a>
                </li>
                <li style="border: 0;padding-right: 0;">
                    <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=137279587&site=qq&menu=yes">联系我们</a>
</li>
            </ul>
            <ul id="ulStudent" class="hide">
                <li>
                    <a href="javascript:void(0)" class="link-login"><img src="/static/images/releasePic.png" class="link-l-pic" /><span id="spanName">社团名称</span></a>
                    <div class="link-list">
                        <p id="pSupport"><a href="/my/support.html">我的赞助</a></p>
                        <p><a href="/my/invite.html">我的邀请</a></p>
                        <p><a href="/my/contract.html">我的合同</a></p>
                        <p><a href="/my/sponsor.html">我的收藏</a></p>
                        <!--<p><a href="/personal/associate/account.html">账户信息</a></p>-->
                    </div>
                </li>
                <li>
                    <a href="javascript:void(0)" class="link-login ml25"><img src="/static/images/releaseMessage.png" class="link-l-message" />消息</a>
                    <div class="link-list">
                        <p><a href="/my/systemNotice.html">系统消息</a></p>
                        <!-- <p>信息回复</p> -->
                    </div>
                </li>
                <li style="border: 0;">
                    <a href="javascript:void(0)" class="link-login">设置</a>
                    <div class="link-list">
                        <!--<p id="pCharge"><a href="#">负责人信息</a></p>-->
                        <p><a id="btnInfo" href="#">个人信息</a></p>
                        <!--<p><a href="#">修改密码</a></p>-->
                        <!--<p>收款账号</p>-->
                        <p><a href="javascript:void(0)" onclick="Logout()">退出登录</a></p>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
<div class="header">
    <div class="container">
        <div class="clearfix">
            <div class="logo fl"><img src="/static/images/logo.png" alt=""></div>
            <div class="type fl">
                <h2 id="h2Name">社团</h2>
            </div>
            <!-- <div class="city fl"><span>广州</span><a href="javascript:void(0)">[切换城市]</a></div> -->
            <div class="search fr">
                <input id="txtName" type="text" placeholder="请输入高校名称">
                <button type="button" onclick="GoSearch()"></button>
            </div>
        </div>
    </div>
</div>
<script>

    //var userType = common.GetUserType();
    var user = common.GetUser();
    var type = common.checkValue(user) ? $.parseJSON(user).UserType : "";

    CheckUser(type);

    function CheckUser(userType) {

        if (common.checkValue(userType)) {

            switch (userType) {
                case 1:
                    $("#spanName").html("个人中心");
                    $("#h2Name").html("企业");
                    $("#btnApply").attr("href", "/company/register.html");
                    break;
                case 2:
                    $("#spanName").html("个人中心");
                    $("#h2Name").html("社团");
                    $("#btnApply").attr("href", "/personal/register.html");
                    break;
                case 3:
                    $("#spanName").html("个人中心");
                    $("#h2Name").html("代理官");
                    $("#btnApply").attr("href", "/agent/register.html");
                    break;
            }

            if (common.checkValue(user)) {
                $("#ulStudent").show();
                $("#ulUnlogin").hide();
                $("#publish-text").bind("click", HeaderReleseProject);
                var $pSupport = $("#pSupport");

                switch (type) {
                    case 1:
                        $("#publish-text").html("发布企业赞助");
                        $pSupport.find("a").html("我的赞助")
                        $("#btnInfo").attr("href", "/company/company/companyInfo.html");
                        break;
                    case 2:
                        $("#publish-text").html("发布社团筹备");
                        $pSupport.find("a").html("我的筹备")
                        $("#btnInfo").attr("href", "/personal/associate/commuityInfo.html");
                        break;
                    default:
                        $("#publish-text").hide();
                        $pSupport.hide();
                        $("#btnInfo").attr("href", "/agent/agent/commuityInfo.html");
                        break;
                }
            }
            else {
                $("#publish-text").html("发布活动");
                $("#publish-text").unbind();
                $("#publish-text").click(function () {
                    common.showMessage("请登录后操作", function () {
                        window.location = "/login.html";
                    })
                });

            }

        }
        else {
            //未登录
            $("#publish-text").html("发布活动");
            $("#publish-text").unbind();
            $("#publish-text").click(function () {
                common.showMessage("请登录后操作", function () {
                    window.location = "/login.html";
                })
            });
            //$("#publish-text").hide();
            $("#ulUnlogin").show();
        }
    }

    function HeaderReleseProject() {
        common.commonAjax({ type: 'Get', url: '/api/user/HasVerified', sMethod: AfterHeaderVerified });
    }

    function AfterHeaderVerified(ctx) {
        if (ctx == null) {
            common.alertMessage("无数据.");
            return;
        }

        if (ctx.ResponseDict.HasVerified == "Y") {
            window.location = "/release.html";
        }
        else {
            common.showMessage(ctx.ResponseDict.Message, function () {
                if (type == 1)
                    window.location = "/company/register.html";
                else
                    window.location = "/personal/register.html";
            })
        }
    }

    function Logout() {
        common.commonAjax({ type: 'Get', url: '/api/user/Logout' });
        common.RemoveUser();
        window.location = "/index.html";
    }

    function GoSearch() {
        location.href = "/search.html?sn=" + escape($("#txtName").val());
    }

    $('.link-login').on('click', function (e) {

        var self = $(this);
        self.parent().siblings().find('a').removeClass('on');
        self.toggleClass('on');
    });

</script>
